package cn.thoughtworks.school.contract;

import cn.thoughtworks.school.Application;
import cn.thoughtworks.school.services.AmazonClientService;
import com.github.database.rider.core.api.configuration.DBUnit;
import com.github.database.rider.core.api.dataset.DataSet;
import com.github.database.rider.spring.api.DBRider;
import io.restassured.module.mockmvc.RestAssuredMockMvc;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.WebApplicationContext;

import java.io.File;


@Ignore
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
@ActiveProfiles("test")
//@AutoConfigureStubRunner
@Transactional
@DBRider
@DBUnit(caseSensitiveTableNames = true)
@DataSet("onlinecodingsubmission.yml")
public class OnlineCodingQuizSubmissionBase {
    @Autowired
    private WebApplicationContext wac;

    @MockBean
    private RestTemplate restTemplate;
    @MockBean
    private AmazonClientService amazonClientService;

    @Before
    public void setup() {
        Mockito.when(restTemplate.getForEntity(Mockito.anyString()
                , Mockito.any(Class.class))).thenReturn(new ResponseEntity<>("nice", HttpStatus.OK));

        Mockito.when(amazonClientService.getFile(Mockito.anyString(), Mockito.anyString())).thenReturn(new File("test"));

        RestAssuredMockMvc.webAppContextSetup(wac);
    }
}
